package com.xd.core.company.controller;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xd.core.company.entity.TowBindBank;
import com.xd.core.company.service.ITowBindBankService;
import com.xd.core.company.vo.TowBindBankVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 通道二提现账户白名单 前端控制器
 * </p>
 *
 * @author ZX
 * @since 2025-06-20
 */
@Api(tags = "通道二提现账户白名单API")
@RestController
@RequestMapping("/company/tow-bind-bank")
public class TowBindBankController {

    @Autowired
    private ITowBindBankService iTowBindBankService;

    @ApiOperation("新增通道二白名单")
    @PostMapping("/add")
    public void add(@RequestBody TowBindBank towBindBank) {
        iTowBindBankService.add(towBindBank);
    }

    @ApiOperation("白名单下拉框")
    @GetMapping("/list/{companyId}")
    public List<TowBindBankVo> list(@PathVariable Integer companyId) {
        List<TowBindBank> list = iTowBindBankService.list(new LambdaQueryWrapper<TowBindBank>().eq(TowBindBank::getCompanyId, companyId));
        return BeanUtil.copyToList(list,TowBindBankVo.class);
    }

    @ApiOperation("白名单列表")
    @GetMapping("/getList/{companyId}")
    public List<TowBindBank> getList(@PathVariable Integer companyId) {
        return iTowBindBankService.list(new LambdaQueryWrapper<TowBindBank>().eq(TowBindBank::getCompanyId, companyId));
    }

}
